<?php include("../config.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title><?php echo $sitename; ?> - Sysop: Database and tables creation</title>
<meta name="description" content="<?php echo $sitename; ?> - Sysop: Rate Software">
<meta name="keywords" content="free to try, software, shareware, freeware, developers, vendors, download, PAD">
<meta name="author" content="Andrey Aleksanyants, M.D.">
<meta name="copyright" content="easy HTools">
<meta http-equiv="imagetoolbar" content="no">
<link rel="stylesheet" type="text/css" href="../<?php echo $cssfile; ?>">
<link rel="shortcut icon" href="../favicon.ico">
</head>
<body>
<table class="tmain" align="center" width="90%" cellspacing="0" cellpadding="0">
<tr>
<td class="tmain">
<table class="tlogo" align="center" width="100%" cellspacing="0" cellpadding="4">
<tr>
<td align="right">
<p><a href="index.php">Home</a></p>
</td>
</tr>
</table>
</td>
</tr><tr>
<td class="tmain">
<br>
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="1">
<tr valign="top">
<td class="tbody">
<h1><?php echo $sitename; ?> - Sysop: Database and tables creation<h1>
<?php

if(($userid == "user") | ($userpassword == "password") | ($dbname == "database")) {
	echo "<p><b>Error:</b> You did not change the default settings for user ID, password, or database name in \"def.php\" file!.</p>\n";
	exit;
}

if(!($link_id = mysql_connect($dbhost, $userid, $userpassword))) {
	echo "<p><b>Error connecting to the database server:</b> " . mysql_error() . "</p>\n";
	echo "<p>In order to access the MySql database, the same username and password, must be entered in the MySql my.ini file. This requirement is a security protection to insure that sites built with this kit are not vulnerable to a breakin at one site exposing these variables giving instant access to variables at unrelated sites.</p>\n";
	exit;

}
echo "<h1>Connected to the mySQL server...</h1>\n";

if(!mysql_query("CREATE DATABASE IF NOT EXISTS $dbname")) die("<p><b>Error creating ". $dbname . " database:</b> " . mysql_error() . "</p>\n");
echo "<p>Successfully created the " . $dbname . " database.</p>\n";

mysql_select_db($dbname);

// Creating PADDATA table
$tablename = "paddata";
$fields  = "progid int(6) NOT NULL primary key auto_increment,";
$fields .= "company varchar(50) NOT NULL,";
$fields .= "country varchar(50),";
$fields .= "website varchar(128),";
$fields .= "contactname varchar(128),";
$fields .= "email varchar(50),";
$fields .= "title varchar(50) NOT NULL,";
$fields .= "version varchar(10),";
$fields .= "pdate date,";
$fields .= "cost float,";
$fields .= "ptype varchar(15),";
$fields .= "status enum('0', '1') default '0',";
$fields .= "install varchar(50),";
$fields .= "os varchar(80),";
$fields .= "languages varchar(255),";
$fields .= "changeinfo text,";
$fields .= "category varchar(80) NOT NULL,";
$fields .= "requirements varchar(200),";
$fields .= "ksize int,";
$fields .= "keywords varchar(128),";
$fields .= "description varchar(84),";
$fields .= "descrlarge text,";
$fields .= "homepage varchar(128),";
$fields .= "screenshot varchar(128),";
$fields .= "icon varchar(128),";
$fields .= "padfile varchar(128),";
$fields .= "download varchar(128),";
$fields .= "aspnumber varchar(5),";
$fields .= "affiliate enum('RegNow', 'Share-It', 'eSellerate', 'Plimus'),";
$fields .= "affiliateid varchar(15),";
$fields .= "dlcount int default '0',";
$fields .= "spotlight int default '0',";
$fields .= "discounturl varchar(128),";
$fields .= "siterating int(1) default '0',";
$fields .= "clean enum('0', '1') default '0',";
$fields .= "poll int default '0',";
$fields .= "index (progid, company, title)";

if(!mysql_query("CREATE TABLE IF NOT EXISTS $tablename($fields)")) die("<p><b>Error creating " . $tablename . " table:</b> " . mysql_error() . "</p>\n");
echo "<p>Successfully created \"" . $tablename . "\" table.</p>\n";

// Creating SUBMITLOG table
$tablename = "submitlog";
$fields  = "submid int(6) NOT NULL primary key auto_increment,";
$fields .= "logtime datetime,";
$fields .= "ipaddr varchar(20),";
$fields .= "company varchar(50) NOT NULL,";
$fields .= "country varchar(50),";
$fields .= "website varchar(128),";
$fields .= "contactname varchar(128),";
$fields .= "email varchar(50),";
$fields .= "title varchar(50) NOT NULL,";
$fields .= "version varchar(10),";
$fields .= "pdate date,";
$fields .= "cost float,";
$fields .= "ptype varchar(15),";
$fields .= "install varchar(50),";
$fields .= "os varchar(80),";
$fields .= "languages varchar(255),";
$fields .= "changeinfo text,";
$fields .= "category varchar(80) NOT NULL,";
$fields .= "requirements varchar(200),";
$fields .= "ksize int,";
$fields .= "keywords varchar(128),";
$fields .= "description varchar(84),";
$fields .= "descrlarge text,";
$fields .= "homepage varchar(128),";
$fields .= "screenshot varchar(128),";
$fields .= "icon varchar(128),";
$fields .= "padfile varchar(128),";
$fields .= "download varchar(128),";
$fields .= "aspnumber varchar(5),";
$fields .= "backlink varchar(128),";
$fields .= "affiliate enum('RegNow', 'Share-It', 'eSellerate', 'Plimus'),";
$fields .= "affiliateid varchar(15)";

if(!mysql_query("CREATE TABLE IF NOT EXISTS $tablename($fields)")) die("<p><b>Error creating " . $tablename . " table:</b> " . mysql_error() . "</p>\n");
echo "<p>Successfully created \"" . $tablename . "\" table.</p>\n";

// Creating USRREVIEWS table
$tablename = "usrreviews";
$fields  = "revid int(6) NOT NULL primary key auto_increment,";
$fields .= "progid int(6) NOT NULL,";
$fields .= "useripaddr varchar(20),";
$fields .= "revtime varchar(30),";
$fields .= "username varchar(50),";
$fields .= "userrating int(1) default '0',";
$fields .= "usercomment text";

if(!mysql_query("CREATE TABLE IF NOT EXISTS $tablename($fields)")) die("<p><b>Error creating " . $tablename . " table:</b> " . mysql_error() . "</p>\n");
echo "<p>Successfully created \"" . $tablename . "\" table.</p>\n";

// Creating CUSTOMURLS table
$tablename = "customurls";
$fields  = "customid int(6) NOT NULL primary key auto_increment,";
$fields .= "progid int(6) NOT NULL,";
$fields .= "customurl varchar(200)";

if(!mysql_query("CREATE TABLE IF NOT EXISTS $tablename($fields)")) die("<p><b>Error creating " . $tablename . " table:</b> " . mysql_error() . "</p>\n");
echo "<p>Successfully created \"" . $tablename . "\" table.</p>\n";
//Creating Helps Table
$tablename = "helps";
$fields = "helpid int(6) NOT NULL primary key auto_increment,";
$fields.= "title varchar(200),";
$fields.= "content text,";
$fields.= "subclass varchar(50),";
$fields.= "date int(20)";
if(!mysql_query("CREATE TABLE IF NOT EXISTS $tablename($fields)")) die("<p><b>Error creating " . $tablename . " table:</b> " . mysql_error() . "</p>\n");
echo "<p>Successfully created \"" . $tablename . "\" table.</p>\n";
//Creating Helps Table
$tablename = "features";
$fields = "featureid int(6) NOT NULL primary key auto_increment,";
$fields.= "progid int(20),";
$fields.= "content text,";
$fields.= "date int(20)";
if(!mysql_query("CREATE TABLE IF NOT EXISTS $tablename($fields)")) die("<p><b>Error creating " . $tablename . " table:</b> " . mysql_error() . "</p>\n");
echo "<p>Successfully created \"" . $tablename . "\" table.</p>\n";
mysql_close($link_id);
echo "<p>Process finished!</p>\n";
?>
<br>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>